.TH wcstombs 3 "" "" ""
.SH SYNOPSIS
wcstombs \- minimal wide char string to multibyte string converter
.SH ANSI_SYNOPSIS
#include <stdlib.h>
.br
int wcstombs(const char *
.IR s ,
wchar_t *
.IR pwc ,
size_t 
.IR n );
.br
.SH TRAD_SYNOPSIS
#include <stdlib.h>
.br
int wcstombs(
.IR s ,
.IR pwc ,
.IR n )
.br
const char *
.IR s ;
.br
wchar_t *
.IR pwc ;
.br
size_t 
.IR n ;
.br
.SH DESCRIPTION
When MB_CAPABLE is not defined, this is a minimal ANSI-conforming 
implementation of 
.BR wcstombs .
In this case,
all wide-characters are expected to represent single bytes and so
are converted simply by casting to char.

When MB_CAPABLE is defined, this routine calls 
.BR _wcstombs_r 
to perform
the conversion, passing a state variable to allow state dependent
decoding. The result is based on the locale setting which may
be restricted to a defined set of locales.
.SH RETURNS
This implementation of 
.BR wcstombs 
returns 
.BR 0 
if
.IR s 
is 
.BR NULL 
or is the empty string; 
it returns 
.BR -1 
if MB_CAPABLE and one of the
wide-char characters does not represent a valid multi-byte character;
otherwise it returns the minimum of: 
.BR n 
or the
number of bytes that are transferred to 
.BR s ,
not including the
nul terminator.

If the return value is -1, the state of the 
.BR pwc 
string is
indeterminate. If the input has a length of 0, the output
string will be modified to contain a wchar_t nul terminator if
.BR n 
> 0.
.SH PORTABILITY
.BR wcstombs 
is required in the ANSI C standard. However, the precise
effects vary with the locale.

.BR wcstombs 
requires no supporting OS subroutines.
.SH SOURCE
src/newlib/libc/stdlib/wcstombs.c
